﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using zhangmenren.IService;
using zhangmenren.Models;
using zhangmenren.Repository;

namespace zhangmenren.Service
{
	public class EnterpriseService: IEnterpriseService
    {
        private EnterpriseRepository enterpriseRepository = new EnterpriseRepository();

        public Task<int> Add(EnterpriseEntity enterprise)
        {
            return Task.FromResult(enterpriseRepository.Add(enterprise));
        }

        public Task<int> Del(int id)
        {
            return Task.FromResult(enterpriseRepository.Del(id));
        
        }

        public Task<int> EditState(int id)
        {
            return Task.FromResult(enterpriseRepository.EditState(id));
        }

        public Task<int> EditSort(int id,int num)
        {
            return Task.FromResult(enterpriseRepository.EditSort(id,num));
        }

        /// <summary>
        /// 查询企业名录  等于false的时候查询所有
        /// </summary>
        /// <returns>The select.</returns>
        /// <param name="isOK">If set to <c>true</c> is ok.</param>
        public Task<IEnumerable<EnterpriseEntity>> Select(bool isOK = false)
        {
            if (isOK)
            {
                return Task.FromResult(enterpriseRepository.Find());
            }
            else 
            {
                return Task.FromResult(enterpriseRepository.Select());
            }


        }
        public Task<IEnumerable<EnterpriseEntity>> Select(int id)
        {
            return Task.FromResult(enterpriseRepository.Select(id));
        }

		public Task<int> AddLiuLan(int id)
		{
			return Task.FromResult(enterpriseRepository.AddLiuLan(id));
		}
	}
}
